<template>
    <div>
        <h2>科室修改</h2>
        <table class="table-table">
            <tr>
                <td>科室名称</td>
                <td>
                    <input type="text" v-model="data.ksmc">
                </td>
            </tr>
            
               <tr>
                <td>科室人数</td>
                <td>
                    <input type="text" v-model="data.ksrs">
                </td>
            </tr>
     
               <tr>
                <td>科室描述</td>
                <td>
                    <input type="text" v-model="data.ksms">
                </td>
            </tr>
               <tr>
                <td>创建日期</td>
                <td>
                    <input type="date" v-model="data.kscjrq">
                </td>
            </tr>
               <tr>
                <td></td>
                <td>
                    <input type="button" value="修改" @click="add">
                </td>
            </tr>
        </table>

    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import moment from 'moment';
import { ref,onMounted } from 'vue';
import { useRoute } from 'vue-router';
const stor= useRoute();



const data=ref({
  "ksid": 0,
  "ksmc": "",
  "ksrs": "",
  "ksms": "",
  "kssc": true,
  "kscjrq": "2025-05-19T03:31:53.687Z"
})


onMounted(()=>{
    ksxs();
   
})
const ksxs=()=>{
    var s= stor.query.ksid
    axios.get("https://localhost:7209/api/Houseksxx/xq",{params:{ksid:s}}).then(res=>{
        data.value=res.data

        data.value.kscjrq = moment(data.value.kscjrq).format("YYYY-MM-DD")
    })
}


const add=()=>{
    debugger
    axios.post("https://localhost:7209/api/Houseksxx/ksupdate",data.value).then(res=>{
        if(res.data>0){
            alert("修改成功");
            location.href="/ksxs"

        }else{
            alert("修改失败")
        }
    })
}
</script>

<style scoped>

</style>